package model;

import base.BaseModel;
import base.BaseObserver;
import base.ResultCallBack;
import bean.GuangGaoBean;
import bean.LoginBean;
import bean.ResultBean;
import jiyun.com.yiyanmeng.http.HttpManager;
import jiyun.com.yiyanmeng.http.MySerivce;
import utils.RxUtil;

/**
 * Created by Windows on 2019/11/5.
 */

public class LoginModel extends BaseModel {
    //请求登录接口
    public void requestLogin(final ResultCallBack<LoginBean> resultCallBack,String name,String pass) {
        MySerivce serivce = HttpManager.getInstance().getSerivce();
        serivce.login(name,pass).compose(RxUtil.<ResultBean<LoginBean>>changeThread())
                .compose(RxUtil.<LoginBean>changeResult())
                .subscribe(new BaseObserver<LoginBean>() {
                    @Override
                    public void onSuccess(LoginBean loginBean) {
                        resultCallBack.onSuccess(loginBean);
                    }

                    @Override
                    public void onFail(String error) {
                        resultCallBack.onFail(error);
                    }
                });
    }
}
